package com.cdn.allmobilestore.widget;

import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;

public class PageScrollListener
  implements AbsListView.OnScrollListener
{
  private Runnable mCallback;
  private boolean mIsLastItem;
  private boolean mOnlyOnePage;

  public PageScrollListener(Runnable callback)
  {
    this.mCallback = callback;
    this.mIsLastItem = false;
    this.mOnlyOnePage = false;
  }

  public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
  {
    boolean bool1 = true;
    boolean bool2;
    if (totalItemCount == firstVisibleItem + visibleItemCount)
    {
      bool2 = bool1;
      this.mIsLastItem = bool2;
      if (totalItemCount != visibleItemCount)
    	  bool1 = false;
    }
    else
    {
      this.mOnlyOnePage = bool1;      
      bool2 = false;      
    }
  }

  public void onScrollStateChanged(AbsListView paramAbsListView, int paramInt)
  {
    if ((paramInt == 0) && (this.mIsLastItem) && (this.mCallback != null) && (!this.mOnlyOnePage))
      this.mCallback.run();
   /* if (paramInt == 2)
      ImageLoader.getInstance().pauseLoading();
    else
      ImageLoader.getInstance().resumeLoading();
    }*/
  }
}

